package com.hnly.djdl.components

import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material.Text
import androidx.compose.material.TextField
import androidx.compose.material.TextFieldDefaults
import androidx.compose.runtime.Composable
import androidx.compose.runtime.MutableState
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import com.hnly.djdl.theme.Neutral3
import com.hnly.djdl.theme.Neutral4

@Composable
fun CustomTextField(
    title: String = "标题",
    textFieldHeight: Dp = 100.dp,
    state: MutableState<String>,
) {
    Column(
        modifier = Modifier
            .fillMaxWidth()
            .padding(horizontal = 12.dp, vertical = 4.dp),
    ) {
        Text(
            text = title,
            style = TextStyle.Default.copy(fontSize = 24.sp, fontWeight = FontWeight.Bold)
        )
        Spacer(modifier = Modifier.height(8.dp))
        TextField(
            value = state.value,
            onValueChange = {
                state.value = it
            },
            modifier = Modifier
                .fillMaxWidth()
                .height(textFieldHeight)
                .clip(RoundedCornerShape(14.dp))
                .background(Neutral4),
            colors = TextFieldDefaults.textFieldColors(
                textColor = Color.Black,
                backgroundColor = Neutral3,
                focusedIndicatorColor = Neutral3,
                unfocusedIndicatorColor = Neutral3
            )
        )
    }
}